import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args){
        String str = "1 2 3 4 5";
        System.out.println(str);
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.add("5");
        String s1 = " ";
        String str2 = "";
        for (String s : list) {
            str2 += s1 + s;
        }
        System.out.println(str2);
        String[] s = str2.split(" ");
        System.out.println("数组第一个元素："+s[0]);
        for (String s2 : s) {
            System.out.println(":"+s2);
        }
//        System.out.println(list);
        System.out.println("-------------------------");
        String str1 = " 1 2 3 4 ";
        System.out.println("str1长度："+str1.length());
        System.out.println("截取长度："+str1.substring(0,1)+":");//左闭右开区间
        System.out.println("截取长度："+str1.substring(0,str1.length())+":");
        System.out.println("截取长度："+str1.substring(0,str1.length()-1)+":");
    }
}
